/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewGameDialog.java
 *
 * Created on 2009-01-18, 21:42:47
 */

package ania2.gui;

import ania2.BoardPosition;

/**
 *
 * @author pawel
 */
public class NewGameDialog extends javax.swing.JDialog {

    public static final int OK_OPTION = 0;
    public static final int CANCEL_OPTION = 1;
    private int value;

    /** Creates new form NewGameDialog */
    public NewGameDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        generalSettingsPanel1 = new ania2.gui.GeneralSettingsPanel();
        positionSetupPanel1 = new ania2.gui.PositionSetupPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        generalSettingsPanel1.setName("generalSettingsPanel1"); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ania2.Ania2App.class).getContext().getResourceMap(NewGameDialog.class);
        jTabbedPane1.addTab(resourceMap.getString("generalSettingsPanel1.TabConstraints.tabTitle"), generalSettingsPanel1); // NOI18N

        positionSetupPanel1.setName("positionSetupPanel1"); // NOI18N
        jTabbedPane1.addTab(resourceMap.getString("positionSetupPanel1.TabConstraints.tabTitle"), positionSetupPanel1); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        value = OK_OPTION;
        this.dispose();
    }//GEN-LAST:event_jButton2MouseClicked

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        value = CANCEL_OPTION;
        this.dispose();
    }//GEN-LAST:event_jButton1MouseClicked

    public int getValue() {
        return value;
    }

    public boolean iswhiteTurn() {
        return generalSettingsPanel1.iswhiteTurn();
    }

    public boolean isComputerPlayingWhites() {
        return generalSettingsPanel1.isComputerPlayingWhites();
    }

    public boolean isComputerPlayingBlacks() {
        return generalSettingsPanel1.isComputerPlayingBlacks();
    }

    public int getTimePerMove() {
        return generalSettingsPanel1.getTimePerMove();
    }

    public void setPosition(BoardPosition position) {
        positionSetupPanel1.setPosition(position);
    }

    public BoardPosition getPosition() {
        return positionSetupPanel1.getPosition();
    }


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                NewGameDialog dialog = new NewGameDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private ania2.gui.GeneralSettingsPanel generalSettingsPanel1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private ania2.gui.PositionSetupPanel positionSetupPanel1;
    // End of variables declaration//GEN-END:variables

}
